﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VOL.Core.Utilities;
using VOL.Domain.Infrastructure;
using VOL.Domain.IServices.SchedulingManagement;
using VOL.Entity.DomainModels.SchedulingManagement;

namespace VOL.Domain.Services.SchedulingManagement
{
    public class TeamTypeModelService:ITeamTypeModelService
    {
        private readonly IBaseRepository<TeamTypeModel> _repository;

        public TeamTypeModelService(IBaseRepository<TeamTypeModel> repository)
        {
            _repository = repository;
        }

        public Task<WebResponseContent> GetTeamType()
        {
            var response = new WebResponseContent();
            try
            {
                // 获取所有团队类型
                var teamTypes = _repository.GetAll().ToList();
                if (teamTypes == null || !teamTypes.Any())
                {
                    return Task.FromResult(response.Error("没有找到班组类型"));
                }
                return Task.FromResult(response.OK("获取成功", teamTypes));
            }
            catch (Exception ex)
            {
                return Task.FromResult(response.Error("获取失败：" + ex.Message));
            }
        }
    }
}
